// 挂载
const Koa = require('koa');
const app = new Koa;

// 挂载
const router = require('koa-router')()
const bodyparser = require('koa-bodyparser')
app.use(router.routes())
app.use(router.allowedMethods())
app.use(bodyparser())

// 挂载
const json = require('koa-json')
app.use(json())

//引入路由文件
const banner = require('./router/index')

//注册路由中间件
app.use(banner.routes(), banner.allowedMethods())

// 挂载
const mysql = require('mysql')

var coonnection = mysql.createConnection({
  host: 'localhost',
  user: 'root',
  password: '253547',
  database: 'node'
})

coonnection.connect(function (err) {
  if (err) {
    console.log("连接失败" + err.stack)
    return;
  }
  console.log("连接成功" + coonnection.threadId)
})

// 3000 端口号
app.listen(3000)
console.log('http://localhost:3000/');



